<script lang="ts" setup>
import PageDialog from "@/components/PageDialog/index.vue";
import {ref} from "vue";

defineOptions({
  name: "rentOrderDetail"
});

/**-------------------表单相关-------------------**/
//参数
const orderInfo = ref({})

/**-------------------打开弹框-------------------**/
//标题
const dialogTitle = ref('')
const dialog = ref()
//弹框显示
const dialogShow = (title: string,data?: object)=>{
  dialogTitle.value = title
  if(data) {
    orderInfo.value = {...data}
  }
  dialog.value.dialogVisible = true
}
defineExpose({
  dialogShow
})

/**-------------------事件回调-------------------**/
//取消
const handlerCancel = ()=> new Promise(async (resolve,reject)=>{
  try{
    dialog.value.dialogVisible = false
    resolve({})
  }catch(e){
    console.log(e)
    reject(e)
  }
})
//确认
const handlerConfirm = ()=> new Promise(async (resolve,reject)=>{
  try{
    dialog.value.dialogVisible = false
    resolve({})
  }catch(e){
    console.log(e)
    reject(e)
  }
})
</script>

<template>
  <PageDialog ref="dialog" :buttons="['confirm']" :handler-cancel="handlerCancel" :handler-confirm="handlerConfirm" :title="dialogTitle" width="60%">
    <el-tabs tab-position="top">
      <el-tab-pane label="基本信息">
        <el-descriptions :column="2" border>
          <el-descriptions-item align="center" label="期数" label-width="200">{{orderInfo.orderNo}}</el-descriptions-item>
          <el-descriptions-item align="center" label="所属站点" label-width="200">{{orderInfo.stationName}}</el-descriptions-item>
          <el-descriptions-item align="center" label="运营商" label-width="200">{{orderInfo.operator}}</el-descriptions-item>
          <el-descriptions-item align="center" label="开始日期" label-width="200">{{orderInfo.orderStart}}</el-descriptions-item>
          <el-descriptions-item align="center" label="结束日期" label-width="200">{{orderInfo.orderEnd}}</el-descriptions-item>
          <el-descriptions-item align="center" label="订单状态" label-width="200">
            <el-tag v-if="orderInfo.status===0" type="info">待确认</el-tag>
            <el-tag v-if="orderInfo.status===1" type="primary">待申请开票</el-tag>
            <el-tag v-if="orderInfo.status===2" type="success">待开票</el-tag>
            <el-tag v-if="orderInfo.status===3" type="warning">已开票</el-tag>
            <el-tag v-if="orderInfo.status===4" type="warning">已回款</el-tag>
            <el-tag v-if="orderInfo.status===5" type="danger">待冲红</el-tag>
            <el-tag v-if="orderInfo.status===6" type="danger">已冲红</el-tag>
            <el-tag v-if="orderInfo.status===7" type="danger">申请驳回</el-tag>
            <el-tag v-if="orderInfo.status===8" type="danger">已作废</el-tag>
          </el-descriptions-item>
          <el-descriptions-item align="center" label="订单备注" label-width="200">{{orderInfo.remark}}</el-descriptions-item>
          <el-descriptions-item v-if="orderInfo.status===7" align="center" label="驳回原因" label-width="200">{{orderInfo.cancelCase}}</el-descriptions-item>
          <el-descriptions-item v-if="orderInfo.status===8" align="center" label="作废原因" label-width="200">{{orderInfo.cancelCase}}</el-descriptions-item>
        </el-descriptions>
      </el-tab-pane>
      <el-tab-pane label="开票信息">
        <el-descriptions :column="2" border>
          <el-descriptions-item align="center" label="订单金额" label-width="200">{{orderInfo.orderPrice}}</el-descriptions-item>
          <el-descriptions-item align="center" label="实收金额" label-width="200">{{orderInfo.realPrice}}</el-descriptions-item>
          <el-descriptions-item align="center" label="开票单位" label-width="200">
            <span v-if="orderInfo.rentSigningUnit===0">晨邦</span>
            <span v-if="orderInfo.rentSigningUnit===1">网基</span>
            <span v-if="orderInfo.rentSigningUnit===2">优居</span>
            <span v-if="orderInfo.rentSigningUnit===3">坤澜</span>
            <span v-if="orderInfo.rentSigningUnit===4">晓鹰</span>
          </el-descriptions-item>
          <el-descriptions-item align="center" label="发票类型" label-width="200">
            <span v-if="orderInfo.rentInvoiceType===0">专票</span>
            <span v-if="orderInfo.rentInvoiceType===1">普票</span>
          </el-descriptions-item>
          <el-descriptions-item align="center" label="税率" label-width="200">{{orderInfo.rentTax}}</el-descriptions-item>
          <el-descriptions-item align="center" label="开票内容" label-width="200">{{orderInfo.rentInvoiceContent}}</el-descriptions-item>
        </el-descriptions>
      </el-tab-pane>
    </el-tabs>
  </PageDialog>
</template>

<style lang="scss" scoped>

</style>
